acceptor_id=0;
proposer_id=0;

all_folder="all/"
cpu_folder="cpu/"
lat_folder="lat/"
sd_avg_folder="sd_avg/"

delimeter="/"
txt_postfix=".txt"
pidstat="pidstat"$txt_postfix;
sirqpidstat="sirq-pidstat"$txt_postfix;
top="top"$txt_postfix;

ip1=$1;
ip2=`expr $1 + $2 `;
config_file=$3;

general_path=$4;


interval=$5;
num_inst=$6;
num_prop=$7;
folder_id=$8;
num_proposers=$9;
last=`expr $9 - 1`
twolast=`expr $last - 1`
shift
diff_num_prop=$9;
 


for((i=ip1; i<ip2; i++))
do
             pidstat_path=$general_path$folder_id$delimeter$cpu_folder$proposer_id$pidstat;
             sirq_pidstat=$general_path$folder_id$delimeter$cpu_folder$proposer_id$sirqpidstat;
             top_path=$general_path$folder_id$delimeter$cpu_folder$proposer_id$top;
    performance_file_path=$general_path$folder_id$delimeter$all_folder$proposer_id$txt_postfix;
        latency_file_path=$general_path$folder_id$delimeter$lat_folder$proposer_id$txt_postfix;
         sd_avg_file_path=$general_path$folder_id$delimeter$sd_avg_folder$proposer_id$txt_postfix;
         
    echo $sd_avg_file_path;
    
    ssh  -f -n  "node"${i} "pidstat 1 |grep APL >> $pidstat_path";
    ssh  -f -n  "node"${i} "pidstat 1 |grep sirq-net-rx >> $sirq_pidstat";
    ssh -f -n "node"${i} "top -b -d 1 | grep APL >> $top_path";
    
    if((num_proposers>0))
    	then
    		send=1;
    	else 
    		send=0;
    fi;
    	
	if((acceptor_id==last))
		then
		    echo $last
			ssh -f -n "node"${i} "/home/parisa/PARISA-NICOLA/trunk/rpaxos-config-4/APL/APL $acceptor_id $proposer_id $config_file $interval $num_inst $diff_num_prop $performance_file_path $latency_file_path $sd_avg_file_path $send";
		else
	   		ssh -f -n "node"${i} "/home/parisa/PARISA-NICOLA/trunk/rpaxos-config-4/APL/APL $acceptor_id $proposer_id $config_file $interval $num_inst $num_prop $performance_file_path $latency_file_path $sd_avg_file_path $send";
	fi
	
    ((acceptor_id+=1));
    ((proposer_id+=1));
    ((num_proposers-=1));
done


#    fi
#	 if ((acceptor_id==twolast))
#			then
#			echo $twolast
#				ssh -f -n "node"${i} "/home/parisa/PARISA-NICOLA/trunk/rpaxos-config-4/APL/APL $acceptor_id $proposer_id $config_file $interval $num_inst 4 $performance_file_path $latency_file_path $sd_avg_file_path $send";
		
